<?php

// html_entity_decode, ktere zachova &amp, &lt, &gt, &quot


// protect entites < > "
$s = strtr($s, "\x05\x06\x07<>\"", "   \x05\x06\x07");
// decode quotes
$s = html_entity_decode($s, ENT_QUOTES, 'UTF-8'); // ENT_NOQUOTES converts &#x22;
// htmlSpecialChars
$s = str_replace(array('&', '<', '>', '"'), array('&amp;', '&lt;', '&gt;', '&quot;'), $s);
// pass back protected entities
$s = strtr($s, "\x05\x06\x07", '<>"');

?>